package com.youzhi.message.kafka;

import cn.hutool.core.util.StrUtil;
import com.youzhi.message.ChannelHolder;
import com.youzhi.message.dto.MessageType;

import java.util.Map;










/**
 * @author xumeng
 * @Date 2023/2/14 下午4:39
 * @Description 发送工作流任务通知给前端用户
 */
public class WorkflowAssigneeTaskNotifyHandler implements IKafkaMessageHandler {

    @Override
    public String getHandlerType() {
        return MessageType.workflow_assignee_task_notify.type;
    }

    @Override
    public void handle(Map<String, Object> data) {
        String websocketId = data.get("webSocketId").toString();
        String message = data.get("message").toString();
        if (StrUtil.isNotEmpty(websocketId)) {
            String text = "{\"type\":\"workflow_assignee_task_notify\",\"message\":\"" + message + "\"}";
            ChannelHolder.broadCast(websocketId, text);
        }
    }
}
